@extends('shop::layouts.master')
@section('title')
    服务订单详情
@endsection
@section('tab')
    <div style="padding: 20px; background-color: #F2F2F2;">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md6">
                <div class="layui-card">
                    <div class="layui-card-header">订单信息</div>
                    <div class="layui-card-body">
                        订单状态：{{$arr_data['state']}} {{$arr_data['is_online_pay'] == 1?'（到付）':''}}<br>
                        订单编号：{{$arr_data['order_number']}} <br>
                        订单类型：{{$arr_data['order_type']==1?'自驾':'代驾'}}<br>
                        商品名称：{{$arr_data['goods_name']}}<br>
                        订单金额：¥{{$arr_data['order_price']}} <br>
                        实付金额：¥{{$arr_data['pay_price']}} <br>
                        优惠金额：¥{{$arr_data['coupon_price']}}<br>
                        支付时间：{{$arr_data['pay_time']}}<br>
                        下单时间：{{$arr_data['created_at']}}<br>
                    </div>
                </div>
            </div>

            <div class="layui-col-md6">
                <div class="layui-card">
                    <div class="layui-card-header">客户信息</div>
                    <div class="layui-card-body">
                        昵称：{{$arr_data['user']['nickname']}} <br>
                        真实姓名：{{$arr_data['user']['realname']}} <br>
                        性别： @if($arr_data['user']['sex']==1)男
                        @elseif($arr_data['user']['sex']==2)女
                        @else保密
                        @endif<br>
                        手机号：{{$arr_data['user']['phone']}} <br>
                        邮箱：{{$arr_data['user']['email']}} <br>
                    </div>
                </div>
            </div>
            @if(!empty($arr_data['order_apprise']))
            <div class="layui-col-md6">
                <div class="layui-card">
                    <div class="layui-card-header">用户评论</div>
                    <div class="layui-card-body" style="overflow-y: hidden;">
                        {{$arr_data['order_apprise']['content']}}
                    </div>
                </div>
            </div>
            @endif
            @if(!empty($arr_data['refund_cause']))
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">申请退款原因</div>
                        <div class="layui-card-body" style="overflow-y: hidden;">
                            {{$arr_data['refund_cause']}}
                        </div>
                    </div>
                </div>
            @endif
            <div class="layui-col-md6">
                <div class="layui-card">
                    <div class="layui-card-header">订单操作</div>
                    <div class="layui-card-body layui_overflow_y" style=" text-align: right">
                        @if(($arr_data['pay_status'] == 1 || $arr_data['pay_status'] == 4) && $arr_data['status'] == 0)
                            <a title="确认处理" class="layui-btn layui-btn-normal" data-title="确认处理完成吗？"
                               data-id="{{$arr_data['id']}}" data-state='1' href="javascript:;">确认处理
                            </a>
                        @endif
                        @if($arr_data['pay_status'] == 0 && $arr_data['status'] == 0)
                            <a title="取消订单" class="layui-btn layui-btn-war" data-title="确认取消订单吗？"
                               data-id="{{$arr_data['id']}}" data-state='2' href="javascript:;">取消订单
                            </a>
                            @if($arr_data['is_online_pay'] == 1 && $arr_data['is_scanning_code'] == 1)
                            <a title="确认处理" class="layui-btn layui-btn-normal" data-title="确认客户已支付 — 并处理完成吗？"
                               data-id="{{$arr_data['id']}}" data-state='1' href="javascript:;">确认处理
                            </a>
                            @endif
                        @endif
                        @if($arr_data['pay_status'] == 2)
                            <a title="确认退款" class="layui-btn layui-btn-warm" data-title="确定退款吗？"
                               data-id="{{$arr_data['id']}}" data-pay_state='3' href="javascript:;">确认退款
                            </a>
                            <a title="拒绝退款" class="layui-btn layui-btn-warm" data-title="确定拒绝退款吗？"
                               data-id="{{$arr_data['id']}}" data-pay_state='4' href="javascript:;">拒绝退款
                            </a>
                        @endif
                            <br>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection

@section('tab_js')
    <script>
        $(document).on('click', '.layui-btn', function () {
            var that = $(this);
            var id = that.data('id');
            var state = that.data('state');
            var pay_state = that.data('pay_state');

            layer.confirm(that.data('title'), {btn: ['确定', '取消']}, function () {
                $.ajax({
                        url: "shop-order-repair-chang-status",
                        type: 'post',
                        dataType: "json",
                        data: {id: id, status: state, pay_status: pay_state},
                        success: function (result) {
                            if (result.state === 0) {
                                layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                    location_refresh();
                                });
                            } else {
                                layer.msg(result.msg, {time: 2000, icon: 5});
                            }
                        }
                    }
                );
            });
        });
    </script>

@endsection